package com.zxy.ziems.server.monitor.convertor;

import com.zxy.ziems.server.device.pojo.entity.DeviceEntity;
import com.zxy.ziems.server.monitor.pojo.dto.MonitorDeviceDTO;
import com.zxy.ziems.server.monitor.pojo.dto.MonitorGroupAddDTO;
import com.zxy.ziems.server.monitor.pojo.entity.MonitorDeviceEntity;
import com.zxy.ziems.server.monitor.pojo.entity.MonitorGroupDeviceEntity;
import com.zxy.ziems.server.monitor.pojo.entity.MonitorGroupEntity;
import com.zxy.ziems.server.monitor.pojo.vo.MonitorDeviceOldVO;
import com.zxy.ziems.server.monitor.pojo.vo.MonitorDeviceVO;
import com.zxy.ziems.server.monitor.pojo.vo.MonitorGroupDeviceVO;
import com.zxy.ziems.server.monitor.pojo.vo.MonitorGroupVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author chdzq
 * @create 2023/3/28
 */
@Mapper(
)
public interface MonitorConvertor {
    MonitorConvertor INSTANCE = Mappers.getMapper(MonitorConvertor.class);


    /**
     * 监控组
     *
     * @param dto
     * @return
     */
    MonitorGroupEntity monitorGroupDTOConvert2DO(MonitorGroupAddDTO dto);

    List<MonitorGroupVO> monitorGroupDOListConvert2VOList(List<MonitorGroupEntity> list);

    /**
     * 监控设备
     *
     * @param monitorDeviceEntityList
     * @return
     */
    List<MonitorDeviceVO> monitorDeviceDOListConvert2VOList(List<MonitorDeviceEntity> monitorDeviceEntityList);

    List<MonitorDeviceEntity> monitorDeviceDTOListConvert2DOList(List<MonitorDeviceDTO> monitorDeviceDTOList);

    @Mapping(target = "id", source = "entity.id")
    @Mapping(target = "groupId", source = "entity.groupId")
    @Mapping(target = "deviceId", source = "entity.deviceId")
    @Mapping(target = "sort", source = "entity.sort")
    @Mapping(target = "deviceName", source = "device.deviceName")
    MonitorGroupDeviceVO monitorGroupDeviceDOConvert2VO(MonitorGroupDeviceEntity entity, MonitorDeviceOldVO device);


    @Mapping(target = "id", source = "entity.id")
    @Mapping(target = "groupId", source = "m.groupId")
    @Mapping(target = "sort", source = "m.sort")
    @Mapping(target = "deviceName", source = "entity.deviceName")
    MonitorDeviceVO monitorDeviceDOListConvert2VO(MonitorGroupDeviceEntity m, MonitorDeviceOldVO entity);


    @Mapping(target = "id", source = "m.id")
    @Mapping(target = "deviceName", source = "m.name")
    MonitorDeviceOldVO monitorDeviceDOConvert2VO(DeviceEntity m, MonitorDeviceVO monitorDeviceVO);
}
